<%@page contentType="text/html; charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="dandelion" uri="http://dandelion.com/tags/dandelion-functions" %> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>实时监控</title>	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link id="favicon" rel="shortcut icon" href="${ctx}/resources/imas/favicon.ico" />
	<link href="${ctx}/resources/vendor/easyui/jquery-easyui-theme/bootstrap/easyui.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/easyui/jquery-easyui-theme/icon.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/easyui/icons/icon-all.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/fontawesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/easyui/jeasyui-extensions/jeasyui.extensions.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/iCheck/skins/all.css" rel="stylesheet" />
	<link href="${ctx}/resources/vendor/alertify/themes/alertify.core.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/resources/vendor/alertify/themes/alertify.default.css" rel="stylesheet" type="text/css" />
	
	<link href="${ctx}/resources/css/manager/commons.css" rel="stylesheet" type="text/css" />
	
	<script src="${ctx}/resources/vendor/jquery/jquery-1.11.3.min.js" type="text/javascript"></script>
	<script src="${ctx}/resources/vendor/easyui/release/jquery.jdirk.min.js"></script>
	<script src="${ctx}/resources/js/common/icons.js"></script>
	<script src="${ctx}/resources/js/common/tools.js"></script>
	<script type="text/javascript">$.extend({"ctx": "${ctx}"});</script>
	
	<script src="${ctx}/resources/vendor/easyui/jquery-easyui-1.3.6/jquery.easyui.min.js" type="text/javascript"></script>
	<script src="${ctx}/resources/vendor/easyui/jquery-easyui-1.3.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="${ctx}/resources/vendor/easyui/release/jeasyui.extensions.all.min.js"></script>
	
	
	<script src="${ctx}/resources/vendor/alertify/lib/alertify.min.js" type="text/javascript"></script>
	<script src="${ctx}/resources/vendor/alertify/alertify_ext.js" type="text/javascript"></script>
	<script src="${ctx}/resources/vendor/iCheck/icheck.min.js"></script>
	<script src="${ctx}/resources/vendor/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	
	<link rel="stylesheet" href="${ctx}/resources/vendor/bootstrap/css/bootstrap.min.css">
	<script src="${ctx}/resources/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script src="${ctx}/resources/vendor/echarts-2.2.7/echarts.js"></script>
</head>

<body style="padding: 10px;overflow-x: hidden;overflow-y: auto;">
	
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-primary">
				<div class="panel-heading">
					<b>会话管理</b>
					<div class="pull-right">
						会话总数
						<span class="badge">${sessionCount}</span>
					</div>
				</div>
				<div style="padding: 0 10px;">
					<table class="table table-hover" style="margin-bottom: 0px;">
						<thead>
							<tr>
								<th style="height:50px;line-height:34px;">序号</th>
					            <th style="height:50px;line-height:34px;">用户名</th>
					            <th style="height:50px;line-height:34px;">主机地址</th>
					            <th style="height:50px;line-height:34px;">最后访问时间</th>
								<th style="height:50px;line-height:34px;">会话ID</th>
					            <th style="height:50px;line-height:34px;">已强制退出</th>
					            <th style="height:50px;line-height:34px;">操作</th>	
							</tr>
						</thead>
						
						<tbody id="tdreadList">
						<c:forEach var="session" items="${sessions}">
							<tr>
								<td>1</td>
								<td>${dandelion:principal(session)}</td>
								<td>${session.host}</td>
								<td><fmt:formatDate value="${session.lastAccessTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								<td>${session.id}</td>
								<td>${dandelion:isForceLogout(session) ? '是' : '否'}</td>
								<td><a href="javascript:forceLogout('${session.id}')">强制退出</a></td>
							</td>
						</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	
	<script>
	function forceLogout(sessionId) {
		$.messager.confirm("您确定要进行该操作？", function (c) { 
			if(c) {
				$.get("${ctx}/manager/system/session/"+sessionId+"/forceLogout", function(result) {
					if (result.status) {
						alertify.success(result.message);
					} else {
						alertify.warning(result.message);
					}
				}, 'JSON');
			}
		});
		
	}
	</script>
</body>
</html>

